// -------------------------------------------------------------------------
//    @Author           :    LvSheng.Huang
//    @Date             :    2016-12-27
//    @Module           :    NFIRankModule
//    @Desc             :
// -------------------------------------------------------------------------


#ifndef NFI_RANK_MODULE_H
#define NFI_RANK_MODULE_H

#include <iostream>
#include "NFIModule.h"
#include "NFComm/NFPluginModule/NFIAsyNosqlModule.h"

class NFIRankModule
    : public NFIModule
{

public:
    enum RANK_TYPE
    {
        RT_NONE,
        RT_INDIVIDUAL_MONEY,
        RT_INDIVIDUAL_WIN_COUNT,
        RT_MAX,
    };

    struct RankValue
    {
        int index;
        int score;
        NFGUID id;
    };

    virtual void AddValue(const NFGUID& self, const RANK_TYPE type, NFINT64 value) = 0;
    virtual void SetValue(const NFGUID& self, const RANK_TYPE type, NFINT64 value) = 0;
    virtual void SubValue(const NFGUID& self, const RANK_TYPE type, NFINT64 value) = 0;

    template<typename BaseType>
    int RangeByIndex(const NFINT64 startIndex, const NFINT64 endIndex, const RANK_TYPE type,
                     BaseType* pBaseType, void (BaseType::*handleReturnRsp)(const NFGUID&, NFMsg::PackNoSqlParam&, const std::string&))
    {
        const NOSQL_RETURN_FUNCTOR FunReturnRsp = std::bind(handleReturnRsp, pBaseType, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
        return RangeByIndex(startIndex, endIndex, type, FunReturnRsp);
    }

    virtual int RangeByIndex(const NFINT64 startIndex, const NFINT64 endIndex, const NFIRankModule::RANK_TYPE type, const NOSQL_RETURN_FUNCTOR& mFunReturnRsp) = 0;
};

#endif